/**
 * 所有渲染，屏幕
 */
//共有
var LAYER_AUTO = 0;
var LAYER_BY = 1;
var LAYER_BG = 2;
var LAYER_BG_0 = 3;

//渲染生产线
var RanderJobLst_Beyound=new Array();
var RanderJobLst_Backgournd=new Array();
var RanderJobLst_Backgournd0=new Array();

//screen
var screenx;
var screeny;
var randerTT=0;


var cxt;var cxtb;
var m_canvas;
RanderJob  = function (){
	this.x;
	this.y;
	this.imgobj;
}

function InitGraphic(canid){
	var c=document.getElementById(canid);
	
	/*if (Option_PreRender){
		cxtb=c.getContext('2d');
		m_canvas = document.createElement('canvas');
		m_canvas.width = SCREENW;
		m_canvas.height = SCREENH;
		cxt=m_canvas.getContext('2d');
	}else{ */
		cxt=c.getContext('2d');
	/*}
	*/

}



function RedrawScreen(){
	
	requestAnimFrame(RedrawScreen);
	if (mappic[0]==null || onloading==1 || isPreloading ==1) return;
	cxt.clearRect(0, 0, SCREENW, SCREENH);
	cxt.translate(screenx, screeny); 

	
	if (DEBUG){
		var t = new Date();
		var d = t.getTime();
		document.getElementById("debuginfo").value=(d - randerTT);
		randerTT =d;
	}
	
	cxt.drawImage(mappic[0],0,0);
	
	for (i=0;i<RanderJobLst_Backgournd0.length;i++){
		cxt.drawImage(
				RanderJobLst_Backgournd0[i].imgobj,
				RanderJobLst_Backgournd0[i].x,
				RanderJobLst_Backgournd0[i].y
				);
	}
	
	for (i=0;i<RanderJobLst_Backgournd.length;i++){
		cxt.drawImage(
				RanderJobLst_Backgournd[i].imgobj,
				RanderJobLst_Backgournd[i].x,
				RanderJobLst_Backgournd[i].y
				);
	}
	if (mappic[2]!=null)
		cxt.drawImage(mappic[2],0,0);
	
	//drawmasklayer
	if (mappic[1]!=null){
		if (Option_MaskTran) cxt.globalAlpha = 0.5;
		cxt.drawImage(mappic[1],0,0);
		if (Option_MaskTran) cxt.globalAlpha = 1;
	}
	
	for (i=0;i<RanderJobLst_Beyound.length;i++){
		cxt.drawImage(
				RanderJobLst_Beyound[i].imgobj,
				RanderJobLst_Beyound[i].x,
				RanderJobLst_Beyound[i].y
				);
	}
	
	cxt.translate(-screenx, -screeny);
	
	//if (Option_PreRender) cxtb.drawImage(m_canvas, 0, 0);

}

